package com.itheima.manager;

import com.itheima.common.R;
import com.itheima.domain.OmsOrderReturnApply;
import com.itheima.service.OmsOrderReturnApplyService;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

@Component
public class OmsOrderReturnApplyManager {

    @DubboReference
    OmsOrderReturnApplyService omsOrderReturnApplyService;

    //分页查询退货申请
    public R findByPage(String createTime, String handleMan, String handleTime, Integer id, Integer pageNum, Integer pageSize, String receiverKeyword, Integer status) {
        PageBeanVo vo= omsOrderReturnApplyService.findByPage(createTime,handleMan,handleTime,id, pageNum,pageSize,receiverKeyword,status);

        return R.success(vo);
    }

    //获取退货申请详情
    public R getOrderReturn(Long id) {
        OmsOrderReturnApply omsOrderReturnApply = omsOrderReturnApplyService.findById(id);

        return R.success(omsOrderReturnApply);
    }

    //修改退货申请状态
    public void updateStatus(Integer id, OmsOrderReturnApply omsOrderReturnApply) {
        omsOrderReturnApply.setId(id.longValue());
        omsOrderReturnApply.setHandleTime(LocalDateTime.now());
        if (omsOrderReturnApply.getStatus() == 2) {
            omsOrderReturnApply.setReceiveTime(LocalDateTime.now());
        }
        omsOrderReturnApplyService.updateStatus(omsOrderReturnApply);
    }
    //批量删除退货申请
    public void delete(List<Long> ids) {
        omsOrderReturnApplyService.delete(ids);
    }
}
